﻿<UserControl x:Class="Qero.ChartPoint.AppSetup"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="350" d:DesignWidth="510" Loaded="UserControl_Loaded" Background="#FFE9E9E9" xmlns:my="clr-namespace:Qero.ChartPoint">
    <UserControl.Resources>
        <my:NodeCornersConverter x:Key="nodeCornersConvert" />
        <my:TestValueConverter x:Key="testValueConvert" />
        <LinearGradientBrush x:Key="ButtonActBack" StartPoint="1,0" EndPoint="1,1">
            <GradientStop Color="#FFDAF0FC" Offset=".2"/>
            <GradientStop Color="#FFE7F5FD" Offset=".6"/>
            <GradientStop Color="#FFBDE6FD" Offset=".6"/>
            <GradientStop Color="#FFABDBF6" Offset=".9"/>
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="ButtonStillBack" StartPoint="1,0" EndPoint="1,1">
            <GradientStop Color="#FFCFCFCF" Offset=".7"/>
            <GradientStop Color="Transparent" Offset=".2"/>
        </LinearGradientBrush>
        <Storyboard x:Key="ShowShine">
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Shine" Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="1"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="HideShine">
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Shine" Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Style x:Key="SelectHighlight" TargetType="{x:Type ListBoxItem}">
            <Style.Resources>
                <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#FFF0F0F0"/>
            </Style.Resources>
        </Style>
        <Style x:Key="ChangeDeselectLineBack">
            <Style.Triggers>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" Value="True">
                    <Setter Property="Control.Visibility" Value="Visible" />
                </DataTrigger>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" Value="False">
                    <Setter Property="Control.Visibility" Value="Collapsed" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
        <Style x:Key="ChangeSelectedLineBack">
            <Style.Triggers>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" Value="True">
                    <Setter Property="Control.Visibility" Value="Hidden" />
                </DataTrigger>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" Value="False">
                    <Setter Property="Control.Visibility" Value="Visible" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
        <Style x:Key="ButtonFocusVisual">
            <Setter Property="Control.Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Border>
                            <Rectangle SnapsToDevicePixels="true" Margin="4" Stroke="Black" StrokeDashArray="1 2" StrokeThickness="1"/>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="RightTwinButton" TargetType="{x:Type Button}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" Value="True">
                    <Setter Property="Control.Visibility" Value="Visible" />
                </DataTrigger>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" Value="False">
                    <Setter Property="Control.Visibility" Value="Collapsed" />
                </DataTrigger>
            </Style.Triggers>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Border CornerRadius="1,6,6,1" BorderThickness="1" RenderTransformOrigin="0.5,0.5" x:Name="border" BorderBrush="#FF707070">
                            <Border.RenderTransform>
                                <TransformGroup>
                                    <ScaleTransform ScaleX="1" ScaleY="1"/>
                                </TransformGroup>
                            </Border.RenderTransform>
                            <Border Background="{TemplateBinding Background}" CornerRadius="1,5,5,0" x:Name="border1" BorderThickness="1" BorderBrush="{StaticResource ButtonStillBack}">
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="1*"/>
                                        <RowDefinition Height=".7*"/>
                                    </Grid.RowDefinitions>
                                    <Border CornerRadius="0,4,0,0" Background="{StaticResource ButtonStillBack}" />
                                    <Border Grid.RowSpan="2" Opacity="0" x:Name="Shine" CornerRadius="0,4,4,0" Background="{StaticResource ButtonActBack}"/>
                                    <ContentPresenter Grid.RowSpan="2" x:Name="contentPresenter"/>
                                </Grid>
                            </Border>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter Property="Opacity" TargetName="border" Value=".5"/>
                                <Setter Property="Opacity" TargetName="contentPresenter" Value=".7"/>
                            </Trigger>
                            <Trigger Property="IsPressed" Value="True">
                                <Setter Property="RenderTransform" TargetName="border">
                                    <Setter.Value>
                                        <TransformGroup>
                                            <ScaleTransform ScaleX="0.9" ScaleY="0.9"/>
                                        </TransformGroup>
                                    </Setter.Value>
                                </Setter>
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="BorderBrush" TargetName="border" Value="#FF3C7FB1" />
                                <Trigger.ExitActions>
                                    <BeginStoryboard Storyboard="{StaticResource HideShine}" x:Name="HideShine_BeginStoryboard"/>
                                </Trigger.ExitActions>
                                <Trigger.EnterActions>
                                    <BeginStoryboard x:Name="ShowShine_BeginStoryboard" Storyboard="{StaticResource ShowShine}"/>
                                </Trigger.EnterActions>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="MiddleTwinButton" TargetType="{x:Type Button}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Border CornerRadius="1" BorderThickness="1" RenderTransformOrigin="0.5,0.5" x:Name="border" BorderBrush="#FF707070">
                            <Border.RenderTransform>
                                <TransformGroup>
                                    <ScaleTransform ScaleX="1" ScaleY="1"/>
                                </TransformGroup>
                            </Border.RenderTransform>
                            <Border Background="{TemplateBinding Background}" x:Name="border1" BorderThickness="1" BorderBrush="{StaticResource ButtonStillBack}">
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="1*"/>
                                        <RowDefinition Height=".7*"/>
                                    </Grid.RowDefinitions>
                                    <Border CornerRadius="0" Background="{StaticResource ButtonStillBack}" />
                                    <Border Grid.RowSpan="2" Opacity="0" x:Name="Shine" Background="{StaticResource ButtonActBack}"/>
                                    <ContentPresenter Grid.RowSpan="2" x:Name="contentPresenter"/>
                                </Grid>
                            </Border>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter Property="Opacity" TargetName="border" Value=".5"/>
                                <Setter Property="Opacity" TargetName="contentPresenter" Value=".7"/>
                            </Trigger>
                            <Trigger Property="IsPressed" Value="True">
                                <Setter Property="RenderTransform" TargetName="border">
                                    <Setter.Value>
                                        <TransformGroup>
                                            <ScaleTransform ScaleX="0.9" ScaleY="0.9"/>
                                        </TransformGroup>
                                    </Setter.Value>
                                </Setter>
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="BorderBrush" TargetName="border" Value="#FF3C7FB1" />
                                <Trigger.ExitActions>
                                    <BeginStoryboard Storyboard="{StaticResource HideShine}" x:Name="HideShine_BeginStoryboard"/>
                                </Trigger.ExitActions>
                                <Trigger.EnterActions>
                                    <BeginStoryboard x:Name="ShowShine_BeginStoryboard" Storyboard="{StaticResource ShowShine}"/>
                                </Trigger.EnterActions>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="LeftTwinButton" TargetType="{x:Type Button}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Border CornerRadius="6,1,1,6" BorderThickness="1" RenderTransformOrigin="0.5,0.5" x:Name="border" BorderBrush="#FF707070">
                            <Border.RenderTransform>
                                <TransformGroup>
                                    <ScaleTransform ScaleX="1" ScaleY="1"/>
                                </TransformGroup>
                            </Border.RenderTransform>
                            <Border Background="{TemplateBinding Background}" CornerRadius="5,1,0,5" x:Name="border1" BorderThickness="1" BorderBrush="{StaticResource ButtonStillBack}">
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="1*"/>
                                        <RowDefinition Height=".7*"/>
                                    </Grid.RowDefinitions>
                                    <Border CornerRadius="4,0,0,0" Background="{StaticResource ButtonStillBack}" />
                                    <Border Grid.RowSpan="2" Opacity="0" x:Name="Shine" CornerRadius="4,0,0,4" Background="{StaticResource ButtonActBack}"/>
                                    <ContentPresenter Grid.RowSpan="2" x:Name="contentPresenter"/>
                                </Grid>
                            </Border>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter Property="Opacity" TargetName="border" Value=".5"/>
                                <Setter Property="Opacity" TargetName="contentPresenter" Value=".7"/>
                            </Trigger>
                            <Trigger Property="IsPressed" Value="True">
                                <Setter Property="RenderTransform" TargetName="border">
                                    <Setter.Value>
                                        <TransformGroup>
                                            <ScaleTransform ScaleX="0.9" ScaleY="0.9"/>
                                        </TransformGroup>
                                    </Setter.Value>
                                </Setter>
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="BorderBrush" TargetName="border" Value="#FF3C7FB1" />
                                <Trigger.ExitActions>
                                    <BeginStoryboard Storyboard="{StaticResource HideShine}" x:Name="HideShine_BeginStoryboard"/>
                                </Trigger.ExitActions>
                                <Trigger.EnterActions>
                                    <BeginStoryboard x:Name="ShowShine_BeginStoryboard" Storyboard="{StaticResource ShowShine}"/>
                                </Trigger.EnterActions>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="UpperTwinButton" TargetType="{x:Type Button}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" Value="True">
                    <Setter Property="Control.Visibility" Value="Visible" />
                </DataTrigger>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" Value="False">
                    <Setter Property="Control.Visibility" Value="Collapsed" />
                </DataTrigger>
            </Style.Triggers>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Border CornerRadius="6,6,1,1" BorderThickness="1" RenderTransformOrigin="0.5,0.5" x:Name="border" BorderBrush="#FF707070">
                            <Border.RenderTransform>
                                <TransformGroup>
                                    <ScaleTransform ScaleX="1" ScaleY="1"/>
                                </TransformGroup>
                            </Border.RenderTransform>
                            <Border Background="{TemplateBinding Background}" CornerRadius="5,5,0,1" x:Name="border1" BorderThickness="1" BorderBrush="{StaticResource ButtonStillBack}">
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="1*"/>
                                        <RowDefinition Height=".7*"/>
                                    </Grid.RowDefinitions>
                                    <Border CornerRadius="0,0,4,0" Background="{StaticResource ButtonStillBack}" />
                                    <Border Grid.RowSpan="2" Opacity="0" x:Name="Shine" CornerRadius="4,4,0,0" Background="{StaticResource ButtonActBack}"/>
                                    <ContentPresenter Grid.RowSpan="2" x:Name="contentPresenter"/>
                                </Grid>
                            </Border>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter Property="Opacity" TargetName="border" Value=".5"/>
                                <Setter Property="Opacity" TargetName="contentPresenter" Value=".7"/>
                            </Trigger>
                            <Trigger Property="IsPressed" Value="True">
                                <Setter Property="RenderTransform" TargetName="border">
                                    <Setter.Value>
                                        <TransformGroup>
                                            <ScaleTransform ScaleX="0.9" ScaleY="0.9"/>
                                        </TransformGroup>
                                    </Setter.Value>
                                </Setter>
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="BorderBrush" TargetName="border" Value="#FF3C7FB1" />
                                <Trigger.ExitActions>
                                    <BeginStoryboard Storyboard="{StaticResource HideShine}" x:Name="HideShine_BeginStoryboard"/>
                                </Trigger.ExitActions>
                                <Trigger.EnterActions>
                                    <BeginStoryboard x:Name="ShowShine_BeginStoryboard" Storyboard="{StaticResource ShowShine}"/>
                                </Trigger.EnterActions>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="DownTwinButton" TargetType="{x:Type Button}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" Value="True">
                    <Setter Property="Control.Visibility" Value="Visible" />
                </DataTrigger>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" Value="False">
                    <Setter Property="Control.Visibility" Value="Collapsed" />
                </DataTrigger>
            </Style.Triggers>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Path Stretch="Fill" Fill="#FF707070" Data="F1 M 319,295L 311,295C 307.691,295 305.008,292.322 305,289.016L 305,281.062C 305,280.51 305.573,280 306.125,280L 323.958,280C 324.508,280 324.996,280.513 325,281.062L 325,286L 325,289C 325,292.314 322.314,295 319,295 Z "/>
                            <Border CornerRadius="1,1,6,6" BorderThickness="1" RenderTransformOrigin="0.5,0.5" x:Name="border" BorderBrush="#FF707070" Background="Silver">
                                <Border.RenderTransform>
                                    <TransformGroup>
                                        <ScaleTransform ScaleX="1" ScaleY="1"/>
                                    </TransformGroup>
                                </Border.RenderTransform>
                                <Border Background="{TemplateBinding Background}" CornerRadius="0,1,5,5" x:Name="border1" BorderThickness="1" BorderBrush="{StaticResource ButtonStillBack}">
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="1*"/>
                                            <RowDefinition Height=".4*"/>
                                        </Grid.RowDefinitions>
                                    
                                        <Border CornerRadius="0,0,0,4" Background="{StaticResource ButtonStillBack}" />
                                        <Border Grid.RowSpan="2" Opacity="0" x:Name="Shine" CornerRadius="0,0,4,4" Background="{StaticResource ButtonActBack}"/>
                                        <ContentPresenter Grid.RowSpan="2" x:Name="contentPresenter"/>
                                    </Grid>
                                </Border>
                            </Border>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter Property="Opacity" TargetName="border" Value=".5"/>
                                <Setter Property="Opacity" TargetName="contentPresenter" Value=".7"/>
                            </Trigger>
                            <Trigger Property="IsPressed" Value="True">
                                <Setter Property="RenderTransform" TargetName="border">
                                    <Setter.Value>
                                        <TransformGroup>
                                            <ScaleTransform ScaleX="0.9" ScaleY="0.9"/>
                                        </TransformGroup>
                                    </Setter.Value>
                                </Setter>
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="BorderBrush" TargetName="border" Value="#FF3C7FB1" />
                                <Trigger.ExitActions>
                                    <BeginStoryboard Storyboard="{StaticResource HideShine}" x:Name="HideShine_BeginStoryboard"/>
                                </Trigger.ExitActions>
                                <Trigger.EnterActions>
                                    <BeginStoryboard x:Name="ShowShine_BeginStoryboard" Storyboard="{StaticResource ShowShine}"/>
                                </Trigger.EnterActions>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <DataTemplate x:Key="chartTemplate">
            <Border BorderBrush="#FF828790" BorderThickness="1" CornerRadius="{Binding Path=chartMake, Converter={StaticResource nodeCornersConvert}}" Padding="2,3,2,4" Margin="0,0,2,-1">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="26"/>
                        <ColumnDefinition Width="32"/>
                        <ColumnDefinition Width="178"/>
                        <ColumnDefinition Width="1*"/>
                    </Grid.ColumnDefinitions>
                    <Rectangle Grid.ColumnSpan="4" Fill="White" Height="3" HorizontalAlignment="Stretch" Style="{StaticResource ChangeSelectedLineBack}" Margin="0,-3,0,0" VerticalAlignment="Top" IsManipulationEnabled="True" />
                    <Rectangle Grid.ColumnSpan="4" Fill="White" Height="3" HorizontalAlignment="Stretch" Style="{StaticResource ChangeSelectedLineBack}" Margin="0,0,0,-3" VerticalAlignment="Bottom" />
                    <Button Name="getSaveChart" HorizontalAlignment="Left" Height="22" Width="24" Style="{StaticResource DownTwinButton}" Margin="2,-9,0,0" Command="{Binding Path=SaveCommand}" Click="SaveChart_Click"> 
                        <Image Height="15" Width="15" Source="/Qero.ChartPoint;component/Pics/SaveIcon.png" />
                    </Button>
                    <Image Grid.Column="1" Width="24" Height="24" Source="{Binding Path=picPath}"/>
                    <TextBlock Grid.Column="2" Text="{Binding Path=chartName}" Height="16" Foreground="#FF3B3B3B" Style="{StaticResource ChangeSelectedLineBack}" HorizontalAlignment="Left" Margin="12,4,0,0" MaxWidth="170"/>
                    <Border Grid.Column="2" Style="{StaticResource ChangeDeselectLineBack}" Width="170" Height="22" Background="White" BorderBrush="#FF828790" BorderThickness="1" CornerRadius="3" HorizontalAlignment="Left" Margin="8,0,0,0">
                        <TextBox Text="{Binding Path=newItem.chartName, UpdateSourceTrigger=PropertyChanged}" BorderThickness="0" Height="17" Margin="2,3,2,2" LostFocus="ChartName_LostFocus" KeyDown="ChartName_KeyDown" />
                    </Border>
                    <TextBlock Grid.Column="3" Text="Target dir: " Height="16" Foreground="#FF8B96AF" Width="75" TextAlignment="Right" HorizontalAlignment="Left" Margin="2,6,2,2"/>
                    <TextBlock Grid.Column="3" Text="{Binding Path=chartDir}" Margin="78,6,0,0" Height="16" Foreground="#FF3B3B3B" MaxWidth="138" HorizontalAlignment="Left" Style="{StaticResource ChangeSelectedLineBack}" />
                    <Border Grid.Column="3" Style="{StaticResource ChangeDeselectLineBack}" Width="140" Height="22" Background="White" BorderBrush="#FF828790" BorderThickness="1" CornerRadius="3" HorizontalAlignment="Left" Margin="78,0,0,0">
                        <ComboBox Name="selectSub" ItemsSource="{Binding ElementName=charterBorder, Path=DataContext.chartsGroups}" Text="{Binding Path=newItem.chartDir}" Width="136" Height="18" IsEditable="True" BorderThickness="0" BorderBrush="{x:Null}" KeyDown="ChartDir_KeyDown" LostFocus="ChartDir_LostFocus" />
                    </Border>
                    <TextBlock Grid.Column="3" Text="Append files: " Height="16" Foreground="#FF8B96AF" Width="85" TextAlignment="Right" HorizontalAlignment="Left" Margin="217,6,2,2"/>
                    <TextBlock Grid.Column="3" Text="{Binding Path=filesApp}" Height="16" Margin="302,6,0,0" Foreground="#FF3B3B3B" MaxWidth="40" HorizontalAlignment="Left" Style="{StaticResource ChangeSelectedLineBack}" />
                    <Border Grid.Column="3" Style="{StaticResource ChangeDeselectLineBack}" Width="48" Height="22" Background="White" BorderBrush="#FF828790" BorderThickness="1" CornerRadius="3" HorizontalAlignment="Left" Margin="302,0,0,0">
                        <ComboBox Name="selectFile" ItemsSource="{Binding ElementName=charterBorder, Path=DataContext.yesNo}" Text="{Binding Path=newItem.filesApp}" IsEditable="True" IsReadOnly="True" Width="44" Height="18" BorderThickness="0" BorderBrush="{x:Null}" KeyDown="ChartFile_KeyDown" LostFocus="ChartFile_LostFocus" />
                    </Border>
                </Grid>
            </Border>
        </DataTemplate>
        <DataTemplate x:Key="fieldTemplate">
            <Border BorderBrush="#FF828790" BorderThickness="1" CornerRadius="{Binding Path=chartMake, Converter={StaticResource nodeCornersConvert}}" Padding="2,3,2,4" Margin="0,0,2,-1">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="26"/>
                        <ColumnDefinition Width="175"/>
                        <ColumnDefinition Width="1*"/>
                    </Grid.ColumnDefinitions>
                    <Rectangle Grid.ColumnSpan="3" Fill="White" Height="3" HorizontalAlignment="Stretch" Style="{StaticResource ChangeSelectedLineBack}" Margin="0,-3,0,0" VerticalAlignment="Top" IsManipulationEnabled="True" />
                    <Rectangle Grid.ColumnSpan="3" Fill="White" Height="3" HorizontalAlignment="Stretch" Style="{StaticResource ChangeSelectedLineBack}" Margin="0,0,0,-3" VerticalAlignment="Bottom" />
                    <Button Name="getSaveField" HorizontalAlignment="Left" Height="22" Width="24" Style="{StaticResource DownTwinButton}" Margin="2,-9,0,0" Click="SaveField_Click" IsEnabled="False">
                        <Image Height="15" Width="15" Source="/Qero.ChartPoint;component/Pics/SaveIcon.png" />
                    </Button>
                    <TextBlock Grid.Column="1" Text="{Binding Path=fieldName}" Height="16" Foreground="#FF3B3B3B" Style="{StaticResource ChangeSelectedLineBack}" HorizontalAlignment="Left" Margin="12,4,0,0" MaxWidth="170"/>
                    <Border Grid.Column="1" Style="{StaticResource ChangeDeselectLineBack}" Width="163" Height="22" Background="White" BorderBrush="#FF828790" BorderThickness="1" CornerRadius="3" HorizontalAlignment="Left" Margin="8,0,0,0">
                        <TextBox Text="{Binding Path=newItem.fieldName}" BorderThickness="0" Height="17" Margin="2,3,2,2" LostFocus="FieldName_LostFocus" KeyDown="FieldName_KeyDown" />
                    </Border>
                    <TextBlock Grid.Column="2" Text="Field type: " Height="16" Foreground="#FF8B96AF" Width="71" TextAlignment="Right" HorizontalAlignment="Left" Margin="2,6,2,2"/>
                    <TextBlock Grid.Column="2" Text="{Binding Path=fieldType}" Height="16" Foreground="#FF3B3B3B" Style="{StaticResource ChangeSelectedLineBack}" HorizontalAlignment="Left" Margin="74,4,0,0" MaxWidth="170"/>
                    <Border Grid.Column="2" Style="{StaticResource ChangeDeselectLineBack}" Width="90" Height="22" Background="White" BorderBrush="#FF828790" BorderThickness="1" CornerRadius="3" HorizontalAlignment="Left" Margin="74,0,0,0">
                        <ComboBox Name="selectType" ItemsSource="{Binding ElementName=charterBorder, Path=DataContext.fieldsTypes}" Text="{Binding Path=newItem.fieldTypeName}" IsEditable="True" IsReadOnly="True" Width="86" Height="18" BorderThickness="0" BorderBrush="{x:Null}" SelectionChanged="FieldType_SelectionChanged" />
                    </Border>
                    <TextBlock Name="additionCapt" Grid.Column="2" Height="16" Foreground="#FF8B96AF" Width="105" TextAlignment="Right" HorizontalAlignment="Left" Margin="172,6,2,2" />
                    <Border Name="subBorder" Grid.Column="2" Visibility="Hidden" Background="White" BorderBrush="#FF828790" BorderThickness="1" CornerRadius="3" Margin="280,0,20,0">
                        <ComboBox Name="selectSub" IsEditable="True" Height="18" BorderThickness="0" BorderBrush="{x:Null}" KeyDown="selectSub_KeyDown" MouseDoubleClick="selectSub_MouseDoubleClick" />
                    </Border>
                </Grid>
            </Border>
        </DataTemplate>
    </UserControl.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="2*"/>
            <RowDefinition Height="4*"/>
        </Grid.RowDefinitions>
        <!--<Rectangle Grid.ColumnSpan="2" HorizontalAlignment="Stretch" VerticalAlignment="Top" Height="4" Fill="#FFE9E9E9" />
        <Rectangle Grid.ColumnSpan="2" Panel.ZIndex="1" HorizontalAlignment="Stretch" Height="3" Fill="White" Margin="8,5,8,0" VerticalAlignment="Top" />
        <Rectangle Grid.ColumnSpan="2" Panel.ZIndex="1" HorizontalAlignment="Stretch" Height="3" Fill="White" Margin="8,0,8,5" VerticalAlignment="Bottom" />
        <Rectangle Grid.ColumnSpan="2" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Height="4" Fill="#FFE9E9E9" />-->
        <Button Style="{StaticResource DownTwinButton}" Height="18" Width="24" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="13,4,0,0" Panel.ZIndex="2" Click="NewChart_Click">
            <Image Source="/Qero.ChartPoint;component/Pics/AddStar.png" />
        </Button>
        <Rectangle Name="charterBorder" Grid.ColumnSpan="2" Margin="4" Stroke="#FF828790" StrokeThickness="1" RadiusX="4" RadiusY="4" Fill="White" />
        <ListBox Name="chartTable" Grid.ColumnSpan="2" Margin="6,23,6,8" ItemsSource="{Binding Path=ChartSet, Mode=TwoWay}" ItemTemplate="{StaticResource chartTemplate}" ItemContainerStyle="{StaticResource SelectHighlight}" HorizontalContentAlignment="Stretch" BorderThickness="0" />
        
        <TabControl Grid.Row="1" Grid.ColumnSpan="2" Margin="4,0,4,4" TabStripPlacement="Left">
            <TabItem Background="#FFF9F9F9">
                <TabItem.Header>
                    <Border BorderBrush="#FF828790" BorderThickness="1" Margin="-4,0">
                        <Image Source="/Qero.ChartPoint;component/Pics/FieldsIcon.png" Width="24" Height="24"/>
                    </Border>
                </TabItem.Header>
                <TabItem.Content>
                    <Grid>
                        <Rectangle Panel.ZIndex="2" HorizontalAlignment="Stretch" VerticalAlignment="Top" Height="4" Fill="#FFF9F9F9" Margin="-4" />
                        <Rectangle Panel.ZIndex="1" HorizontalAlignment="Stretch" Height="3" Fill="White" Margin="4,1,4,0" VerticalAlignment="Top" />
                        <Rectangle Panel.ZIndex="1" HorizontalAlignment="Stretch" Height="3" Fill="White" Margin="4,0,4,1" VerticalAlignment="Bottom" />
                        <Rectangle HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Height="4" Fill="#FFF9F9F9" Margin="-4" />
                        <Border Name="fielderBorder" Background="White" BorderThickness="1" CornerRadius="4" BorderBrush="#FF828790"></Border>
                        <Button Style="{StaticResource DownTwinButton}" Height="18" Width="24" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="9,0,0,0" Panel.ZIndex="1" Click="NewField_Click">
                            <Image Source="/Qero.ChartPoint;component/Pics/AddStar.png" />
                        </Button>
                        <ListBox Name="chartField" Margin="1,23,1,3" ItemsSource="{Binding Path=SelectedItem.FieldSet, ElementName=chartTable}" ItemTemplate="{StaticResource fieldTemplate}" ItemContainerStyle="{StaticResource SelectHighlight}" HorizontalContentAlignment="Stretch" BorderThickness="0" />
                    </Grid>
                </TabItem.Content>
            </TabItem>
            <TabItem Background="#FFF9F9F9">
                <TabItem.Header>
                    <Border BorderBrush="#FF828790" BorderThickness="1" Margin="-4,0">
                        <Image Source="/Qero.ChartPoint;component/Pics/GroupsIcon.png" Width="24" Height="24"/>
                    </Border>
                </TabItem.Header>
            </TabItem>
            <TabItem Background="#FFF9F9F9">
                <TabItem.Header>
                    <Border BorderBrush="#FF828790" BorderThickness="1" Margin="-4,0">
                        <Image Source="/Qero.ChartPoint;component/Pics/ViewsIcon.png" Width="24" Height="24"/>
                    </Border>
                </TabItem.Header>
            </TabItem>
        </TabControl>
    </Grid>
</UserControl>
